<template>
  <jke-modal
      :visible.sync="jkeForm.visible"
      :width="1200"
      :title="jkeForm.title"
      :fullscreen.sync="jkeForm.fullscreen"
      :switchFullscreen="jkeForm.switchFullscreen"
    >
    <!--  -->
    <crumbs @goBack="goBack" :superiorMenu="['销售管理', '客户管理']" currentMenu="客户详情"> </crumbs>
    <div class="uni-card">
      <div class="bd-line"></div>
      <div class="item-wrap">
        <div class="detail-item" style="width: 20%">
          <p class="subtitle">客户编号</p>
          <p class="secondary-text">{{ detailInfo.customerCode || '-' }}</p>
        </div>
        <div class="detail-item" style="width: 20%">
          <p class="subtitle">客户简称</p>
          <p class="secondary-text">{{ detailInfo.customerShortName || '-' }}</p>
        </div>
        <div class="detail-item" style="width: 20%">
          <p class="subtitle">客户全称</p>
          <p class="secondary-text">{{ detailInfo.customerFullName || '-' }}</p>
        </div>
        <div class="detail-item" style="width: 10%; text-align: right">
          <flow-status
            ids="ERP_CUSTOMER"
            :flowStatusText="detailInfo.flowStatusText"
            :formStatusText="detailInfo.effectStatusText"
            :flowStatus="detailInfo.flowStatus"
          ></flow-status>
        </div>
      </div>
    </div>
    <div class="cards-box">
      <a-card v-if="detailInfo.isInputInvoice == 'yes'" title="开票信息" :bordered="false" style="margin-top: 12px">
        <div class="item-wrap">
          <div class="detail-item">
            <p class="subtitle">公司名称</p>
            <p class="secondary-text">{{ detailInfo.companyName || '-' }}</p>
          </div>
          <div class="detail-item">
            <p class="subtitle">纳税人识别号</p>
            <p class="secondary-text">{{ detailInfo.taxDiscernNum || '-' }}</p>
          </div>
          <div class="detail-item">
            <p class="subtitle">地址</p>
            <p class="secondary-text">{{ detailInfo.address || '-' }}</p>
          </div>
          <div class="detail-item" style="width: 10%; text-align: right"></div>
        </div>
        <div class="item-wrap">
          <div class="detail-item">
            <p class="subtitle">电话</p>
            <p class="secondary-text">{{ detailInfo.phone || '-' }}</p>
          </div>
          <div class="detail-item">
            <p class="subtitle">开户行</p>
            <p class="secondary-text">{{ detailInfo.bankName || '-' }}</p>
          </div>
          <div class="detail-item">
            <p class="subtitle">账号</p>
            <p class="secondary-text">{{ detailInfo.accountNumber || '-' }}</p>
          </div>
          <div class="detail-item" style="width: 10%; text-align: right"></div>
        </div>
        <!-- <div class="item-wrap">
          <div class="detail-item">
            <p class="subtitle">退料时间</p>
            <p class="secondary-text">{{ detailInfo.returnTime || '-' }}</p>
          </div>
          <div class="detail-item" />
          <div class="detail-item" />
        </div>
        <div class="item-wrap">
          <div class="detail-item">
            <p class="subtitle">退料原因</p>
            <p class="secondary-text">{{ detailInfo.reason || '-' }}</p>
          </div>
          <div class="detail-item" />
          <div class="detail-item" />
        </div> -->
      </a-card>
      <a-card v-if="detailInfo.isInputContacts == 'yes'" title="客户联系人" :bordered="false" style="margin-top: 12px">
        <a-table :columns="goodsTable.columns" :data-source="goodsTable.dataSource" :pagination="false"> </a-table>
      </a-card>
      <a-card title="其他信息" :bordered="false" style="margin-top: 12px">
        <div class="item-wrap">
          <div class="detail-item" style="width: 100%">
            <p class="subtitle">客户经理</p>
            <p class="secondary-text">{{ detailInfo.belongUserIdText || '-' }}</p>
          </div>
        </div>
        <div class="item-wrap" style="margin-top: 40px">
          <div style="width: 100%">
            <p class="subtitle">附件</p>
            <file-detail :ids="detailInfo.attachment"></file-detail>
          </div>
        </div>
      </a-card>
      <div style="padding: 12px">
        <Examine  v-if="detailInfo.flowInstId" type="2" :id="detailInfo.flowInstId" ref="examine" />
      </div>
    </div>
  </jke-modal>
</template>
<script>
import crumbs from '@/components/crumbs.vue'
import FileDetail from '@/components/fileActions/FileDetail'
import { returnMaterialQueryById } from '@/api/goodsManagement'
import { API } from '@/api/requestFzs'
import { APILX } from '@/api/requestLx'
import Examine from '@/components/examine'
import FlowStatus from '@/pubComponent/FlowStatus'
import { numFormat } from '@/utils/util'
import LogoVue from '../../../components/tools/Logo.vue'
export default {
  data() {
    return {
      jkeForm: {
        title: '客户详情',
        visible: false,
        fullscreen: true,
        switchFullscreen: true,
      },
      numFormat,
      detailInfo: {},
      flowStatus: {
        RUNNING: { text: '审批中', color: '#FF943E' },
        REFUSE: { text: '已拒绝', color: '#FF4D4F' },
        CANCELED: { text: '已撤回', color: '#888888' },
        AGREE: { text: '已通过', color: '#00B042' },
        TERMINATED: { text: '已终止', color: '#FF4D4F' },
      },
      goodsTable: {
        loading: false,
        dataSource: [],
        columns: [
          {
            title: '姓名',
            width: '10%',
            key: 'contactName',
            dataIndex: 'contactName',
          },
          {
            title: '职务',
            width: '10%',
            key: 'contactPost',
            dataIndex: 'contactPost',
          },
          {
            title: '电话',
            width: '10%',
            key: 'contactPhone',
            dataIndex: 'contactPhone',
          },
          {
            title: '邮箱',
            width: '10%',
            key: 'contactEmail',
            dataIndex: 'contactEmail',
          },
        ],
      },
    }
  },
  components: {
    crumbs,
    FileDetail,
    FlowStatus,
    Examine,
  },
  methods: {
    setColor(s) {
      let cor = {
        1: '#888888',
        2: '#1890FF',
        3: '#00B042',
        REFUSE: '#888888',
        TERMINATED: '#888888',
        RUNNING: '#1890FF',
        AGREE: '#00B042',
      }
      return cor[s] || ''
    },
    /* 面包屑返回 */
    goBack() {
      this.jkeForm.visible = false
    },
    initDetail(id) {
      this.jkeForm.visible = true
      APILX.erpCustomerQueryById(id).then((res) => {
        if (res.code == 200) {
          this.detailInfo = res.result
          this.goodsTable.dataSource = res.result.erpCustomerContactInfoVoList
        } else {
          this.$antdMessage.error(res.result)
        }
      })
    },
  },
}
</script>
<style scoped lang="less">
@import '~@/assets/less/public.less';
.item-wrap {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
}
// .item-wrap:nth-of-type(n + 2) {
//   margin-top: 40px;
// }
.detail-item {
  width: 30%;
}
.uni-card {
  padding: 24px 40px;
  margin: -12px -12px 0;
  background: #fff;
}
.bd-line {
  height: 1px;
  background: @greyBorder;
  margin: -12px -40px 24px -40px;
}
.cards-box {
  height: calc(100vh - 145px);
  overflow-y: scroll;
}
</style>
